package de.tabuma.soapformsweb.controller;

import java.io.*;
import java.util.*;
import de.tabuma.lib.*;
import de.tabuma.soapforms.shopping.*;
import javax.servlet.*;
import javax.servlet.http.*;
import de.tabuma.soapformsweb.view.*;

/**
 *
 * @author alefen
 */
public class controller extends tabumacontroller {

    public controller(String servlet, Hashtable hashtable) {
        super(servlet, hashtable);
    }

    private de.tabuma.soapformsweb.start.controller.controller startcontroller;
    private de.tabuma.customer.controller.controller customercontroller;
    private de.tabuma.soapforms.soapproject.controller.controller soapprojectcontroller;
    private ShoppingController ordercontroller;

    @Override
    public void navigate(ServletContext context, HttpServletRequest request, HttpServletResponse response, PrintWriter out) {
        int mainnav = 0;

        if(request.getParameter(constants.MAIN_NAV)!=null) {
            mainnav = Integer.valueOf(request.getParameter(constants.MAIN_NAV)).intValue();
        }

        head head = new head(this.getServlet(), this.getParameter());
        head.processRequest(context, request, response,out);

        switch(mainnav) {
            case constants.NAV_CUSTOMER:
                        Hashtable hash1 = new Hashtable();
                        hash1.put(constants.MAIN_NAV, "" + constants.NAV_CUSTOMER);
                        customercontroller = new de.tabuma.customer.controller.controller(this.getServlet(), hash1);
                        customercontroller.navigate(context, request, response, out);
                        break;

            case constants.NAV_SOAPPROJECTS:
                        Hashtable hash2 = new Hashtable();
                        hash2.put(constants.MAIN_NAV, "" + constants.NAV_SOAPPROJECTS);
                        soapprojectcontroller = new de.tabuma.soapforms.soapproject.controller.controller(this.getServlet(), hash2);
                        soapprojectcontroller.navigate(context, request, response, out);
                        break;

            case constants.NAV_ORDERS:
                        Hashtable hash3 = new Hashtable();
                        hash3.put(constants.MAIN_NAV, "" + constants.NAV_ORDERS);
                        ordercontroller = new ShoppingController(this.getServlet(), hash3, constants.shoppingParam);
                        ordercontroller.navigate(context, request, response, out);
                        break;

            default:    Hashtable hash = new Hashtable();
                        hash.put(constants.MAIN_NAV, "" + constants.NAV_STARTPAGE);
                        startcontroller = new de.tabuma.soapformsweb.start.controller.controller(this.getServlet(), hash);
                        startcontroller.navigate(context, request, response, out);
                        break;

        }



        bottom bottom = new bottom(this.getServlet(), this.getParameter());
        bottom.processRequest(context, request, response,out);

    }
}